﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DatabaseCore;

namespace Eaktest
{
    public class UserContext
    {
        public static Color COLOR_NORMAL_BG = Color.White;
        public static Color COLOR_NORMAL_FG = Color.Black;

        public static Color COLOR_READONLY_BG = Color.FromArgb(236, 247, 243);
        public static Color COLOR_READONLY_FG = Color.Black;

        private static tbl_User m_userDto;

        #region Singleton of user

        public UserContext(tbl_User user)
        {
            SetUserContext(user);
        }

        public static int Id
        {
            get
            {
                return m_userDto.Id;
            }

            private set
            {
                m_userDto.Id = value;
            }
        }

        public static string Username
        {
            get
            {
                return m_userDto.UserName ?? "Guest";
            }

            private set
            {
                m_userDto.UserName = value;
            }
        }

        public static string Email
        {
            get
            {
                return m_userDto.Email;
            }

            private set
            {
                m_userDto.Email = value;
            }
        }

        public static string FullName
        {
            get
            {
                return m_userDto.FullName ?? "Guest";
            }

            private set
            {
                m_userDto.FullName = value;
            }
        }

        public static int Role
        {
            get
            {
                return m_userDto.Role;
            }

            private set
            {
                m_userDto.Role = value;
            }
        }

        public bool IsLoggedIn()
        {
            return m_userDto != null;
        }

        private void SetUserContext(tbl_User user)
        {
            m_userDto = new tbl_User();
            m_userDto = user;
        }

        #endregion

    }
}
